<?php
class plugx extends CI_Controller {
	function index() {
		$this -> pub -> logp('插件管理', '2', 'plug_plugx');
		$this -> load -> helper('file');
		$da['data'] = get_filenames('./application/config/data/');
		$this -> load -> view('adminx/plugx', $da);
	}

	function set_plug() {
		$this -> pub -> logp('插件数据库生成 ' . $this -> input -> post('url') . ' ' . $this -> input -> post('plug'), '2', 'plug_plugx');
		$da['type'] = 2;
		if ($this -> input -> post('url')) {
			$this -> config -> load('plug_data');
			include './application/config/data/' . $this -> input -> post('url');
			$this -> db = $this -> load -> database($db['default'], TRUE);
			if ($this -> config -> item($this -> input -> post('plug') . '_data')) {
				$da['type'] = 1;
				$ls = explode(';', $this -> config -> item($this -> input -> post('plug') . '_data'));
				foreach ($ls as $v) {
					if (trim($v) != '') {
						$this -> db -> query($v);
					}
				}
			}
		}
		echo json_encode($da);
	}

}
?>